package com.angysnail.guava.string_tools;

import java.util.List;

import com.google.common.base.Joiner;
import com.google.common.base.Splitter;

public class SplitterTest {

	public static void main(String[] args) {
		// 不加skipNulls会报错
		Joiner joiner = Joiner.on(",");
		String value = joiner.skipNulls().join("first", "second", null, "", "three");
		String joinerResult = joiner.join("first", null, "second", "three");
		// first,second,three
		System.out.println(joinerResult);

		Splitter splitter = Splitter.on(",");
		List<String> numbers  = splitter.splitToList("first,second,three");
		System.out.println();

		Joiner joiner1 = Joiner.on(",").skipNulls();
		StringBuilder sb = new StringBuilder("这是我已经写入的内容:");
		String joinerResult1 = joiner1.appendTo(sb, "first", null, "second", "three").toString();
		// 这是我已经写入的内容:first,second,three
		System.out.println(joinerResult1);
	}
}
